package com.sx.zongzhi.presenter;

import com.sx.zongzhi.MyApplication;
import com.sx.zongzhi.bean.PopulationFixedDetailBean;
import com.sx.zongzhi.modle.CollectManager;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.IPopFixedDetailView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by XZY on 2017/11/30.
 *获取留守人员详情
 */
public class PopFixedDetailPest {

    private IPopFixedDetailView detailView;

    public PopFixedDetailPest(IPopFixedDetailView detailView) {
        this.detailView=detailView;
    }


    /**
     *
     * @param id 留守人员id
     */
    public void getPopFixedDetail(String id){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("id", id);
        new CollectManager().getPopFixedDetail(map, new BaseCallBack<BaseResult<PopulationFixedDetailBean>>() {
            @Override
            public void onSuccess(BaseResult<PopulationFixedDetailBean> response) {
                detailView.getFixedDetail(response.getData());
            }
            @Override
            public void onFailures(String message) {
                detailView.showError(message);
            }
        });
    }

    /**
     *
     * @param id 留守人员id
     */
    public void deleteFixed(String id){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("id", id);
        new CollectManager().deleteFixed(map, new BaseCallBack<BaseResult<Boolean>>() {
            @Override
            public void onSuccess(BaseResult<Boolean> response) {
                detailView.deleteFixed(response.getData());
            }
            @Override
            public void onFailures(String message) {
                detailView.showError(message);
            }
        });
    }

}
